/**
 * https://leetcode-cn.com/problems/plus-one/
 */
 var plusOne = function(digits) {
    let carry = false;
    for (i = digits.length - 1; i >=0; i--) {
        carry = digits[i] === 9;
        digits[i] = digits[i] === 9 ? 0 : (digits[i] + 1);
        if (!carry) {
            break;
        }
    }
    if (carry) {
        digits.unshift(1);
    }
    return digits;
};
